﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CashATM
{
    class Model
    {
        string cardNum, Pin;
        int Balance;

        public Model(string cardNum, string Pin, int balance)
        {
            string cardNumber = cardNum;
            string PIN = Pin;
               Balance = balance;             
        }

        public bool login(string cardNumber, string PIN)
        {
            bool jel = false;
            int kezdo = cardNumber.Length;
            int i = kezdo - 4;
            int j = 0;
            do
            {
                if (cardNumber[i] == PIN[j])
                {
                    i++;
                    j++;
                }
            }
            while (i < kezdo);
            if (i < kezdo)
            {
                jel = false;
            }
            else
            {
                jel = true;
            }
            return jel;
        }
        public void logout()
        {

        }
        public int getBalance
        {
            get
            {
                return Balance;
            }
        }
        public bool takeCash(int amount)
        {
            bool jel=false;
            if (amount - Balance > 0)
            {
                Balance = Balance - amount;
                jel = true;
            }
            return jel;
        }
    }
}
